﻿using Logistics.Car;
using Logistics.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; 
using Volo.Abp.Domain.Repositories;

namespace Logistics.examination
{
    public  class ApprovalactivityAppService: ApplicationService, IApprovalactivityAppService
    {
        private readonly IRepository<ApprovalActivity, int> _OwnerRepository;
        private readonly IApprovalActivityRepository _IApprovalActivityRepository;
        public ApprovalactivityAppService(IRepository<ApprovalActivity, int> OwnerRepository, IApprovalActivityRepository IApprovalActivityRepository)
        {

            _OwnerRepository = OwnerRepository;
            _IApprovalActivityRepository = IApprovalActivityRepository;
        }

        public Task<int> Create(int id,int Tid)
        {
            var ok= _IApprovalActivityRepository.Create(id, Tid);
            return ok;
        }

        public async Task<PagedResultDto<ApprovalActivityDto>> GetListAsync(GetApprovalActivityDto dto)
        {
            var vehiclelist = _IApprovalActivityRepository.GetApprovalActivity().Result;
           // var totalCount = await AsyncExecuter.CountAsync(
           //    _OwnerRepository.WhereIf(
           //        !dto.Filter.IsNullOrWhiteSpace(),
           //        m => m.ApprovalUser.Contains(dto.Filter)
           //    )
           //);
           var totalCount=vehiclelist.Count;
            var list=vehiclelist.Skip(dto.SkipCount).Take(dto.MaxResultCount).ToList();
            return new PagedResultDto<ApprovalActivityDto>(
             totalCount,
             ObjectMapper.Map<List<ApprovalActivity>, List<ApprovalActivityDto>>(list));
        }

        public Task<int> UpdateA(int id, int TId, int Did, int AuditStatus, string AuditProposal)
        {
            var q = _IApprovalActivityRepository.UpdateA(id, TId, Did, AuditStatus, AuditProposal);
            return q;

        }

        public Task<int> UpdateB(int id, int AuditStatus, string AuditProposal)
        {
            var q = _IApprovalActivityRepository.UpdateB(id, AuditStatus, AuditProposal);
            return q;
        }
        public Task<int> UpdateC(int id, int TId, int Did)
        {
            var q = _IApprovalActivityRepository.UpdateC(id, TId, Did);
            return q;

        }

        public Task<int> UpdateD(int id)
        {
            var q = _IApprovalActivityRepository.UpdateD(id);
            return q;
        }
    }
}
